<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="java.sql.*,java.util.*,java.text.SimpleDateFormat,java.lang.Math" %>
<%@ include file="classes/conndb.jsp" %>
<%
    request.setCharacterEncoding("UTF-8");
    //session.setAttribute("loginId", "zhuof");//信息中心
    //session.setAttribute("loginId", "nwhzs");//县农业委员会
    //session.setAttribute("loginId", "wangji");//开普互联
    String loginId = (String) (session.getAttribute("loginId") == null ? "" : session.getAttribute("loginId"));//用户ID
%>
<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>ucap list</title><link href="/website-webapp/styles/default/common/pager/page.css" type="text/css" rel="stylesheet"/>
        <script language="javascript" src="/website-webapp/scripts/page.js"></script>
        <script language="javascript" src="/website-webapp/scripts/grid/grid.js"></script>

        <script language="javascript" src="/website-webapp/scripts/jquery.js"></script>

        <script>
            var basePath = 'http://htgl.cnsn.gov.cn/website-webapp';
            var contextPath = '/website-webapp';
            var requestURL = 'http://htgl.cnsn.gov.cn/website-webapp/WEB-INF/pages/view/cm/view/operation/mymanuscript/list.jsp';
            var commonImagesPath = "/website-webapp/images/default/common";

            var popupWindowWidth1 = 390;
            var popupWindowHeight1 = 200;
            var popupWindowWidth2 = 400;
            var popupWindowHeight2 = 390;
            var popupWindowWidth3 = 450;
            var popupWindowHeight3 = 400;
            var popupWindowWidth4 = 800;
            var popupWindowHeight4 = 430;
            var popupWindowWidth5 = 800;
            var popupWindowWidth5a = 810;
            var popupWindowHeight5a = 590;
            var popupWindowHeight5 = 600;
            var popupWindowWidth6 = 1018;
            var popupWindowHeight6 = 750;
            var popupWindowWidth7 = 500;
            var popupWindowHeight7 = 400;
            var popupWindowWidth8 = 650;
            var popupWindowHeight8 = 520;
            var popupWindowWidth9 = 610;
            var popupWindowHeight9 = 530;
            var popupWindowWidth10 = 800;
            var popupWindowHeight10 = 430;
            var popupWindowWidth11 = 520;
            var popupWindowHeight11 = 585;
            var popupWindowWidth12 = 800;
            var popupWindowHeight12 = 530;
                    
            var windowOpenParam="fullscreen=yes,height="+popupWindowHeight6+",width="+popupWindowWidth6+",top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=no, status=yes";
        </script>

        <link href="/website-webapp/styles/default/wcm/operationsview.css" rel="stylesheet" type="text/css" />
        <link href="/website-webapp/styles/default/common/center.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../scripts/view/bodytab-view.js">
        </script>
        <script type="text/javascript" src="/website-webapp/scripts/dialog/lhgcore.min.js">
        </script>
        <script type="text/javascript" src="/website-webapp/scripts/dialog/lhgdialog.js">
        </script>
        <script type="text/javascript" src="http://htgl.cnsn.gov.cn/website-webapp/scripts/wcm/blankhover.js">
        </script>
        <script type="text/javascript" src="/website-webapp/scripts/view/operationsView_init.js">
        </script>
        <script type="text/javascript" src="/website-webapp/scripts/ellipsis_text.js">
        </script>
        <script type="text/javascript" >
            var isEmptyBackLog = "";
            var waitNumber = "";
            var editNumber = "5";
        </script>

    </head>
    <body>
        <table width="528" border="0" cellspacing="0" cellpadding="0" class="operationsview-center-listbar">
            <tr>
                <td width="405" height="22" >标  题&nbsp;</td>
                <td width="123">部    门&nbsp;</td>
            </tr>
        </table>
        <table width="526" border="0" cellspacing="0" cellpadding="0" class="operationsview-center-list public-tablefix"id="listTable1">
            <%  Connection conn = null;
                PreparedStatement pst = null;
                ResultSet rs = null, rss = null, rs2 = null;

                String url = "";
                String sql = "";
                String number = "";
                String depsql = "";
                String depsql2 = "";
                String username = "";
                String deptname = "";
                String userid = "";
                String wheresql = "";
                String undept = "";
                int count = 0;
                //try {
                conn = getConnection();
                depsql = "select login_id,user_id,a.name username,b.name deptname from cms_user a join cms_department  b on a.dept_id=b.dept_id where  a.login_id='" + loginId + "'";
                pst = conn.prepareStatement(depsql);
                rss = pst.executeQuery();
                while (rss.next()) {
                    username = rss.getString("username");
                    deptname = rss.getString("deptname");
                    userid = rss.getString("user_id");
                }
                if (!deptname.equals("开普互联") && !deptname.equals("信息中心")) {
                    wheresql = " and creator_id='" + userid+"'";
                }
                number = request.getParameter("number") == null ? "5" : request.getParameter("number");
                int num = Integer.parseInt(number);
                num = ++num;
                String word_number = request.getParameter("word_number") == null ? "18" : request.getParameter("word_number");
                int word_num = Integer.parseInt(word_number);

                sql = "select * from (select * from nrbz_bh a join cms_manuscript b on a.mid =b.manuscript_id where (a.mid <> 'null' or a.chid <> 'null' or a.un <> 'null') " + wheresql + " order by b.published_time desc) t where rownum < ?";
                //out.print(sql);
                pst = conn.prepareStatement(sql);
                pst.setInt(1, num);

                rs = pst.executeQuery();
                while (rs.next()) {
                    String title = rs.getString("TITLE");
                    title = title.replace("<span>", "").replace("</span>", "");
                    String n = rs.getString("PUBLISHED_TIME");
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                    String dateString = formatter.format(new java.util.Date(Long.parseLong(n)));
                    count = title.length();
                    if (count > word_num) {
                        title = title.substring(0, word_num) + "...";
                    }
                    userid = rs.getString("creator_id");
                    String manuscript_id = rs.getString("manuscript_id");
                    String channel_id = rs.getString("channel_id");
                    url = "http://htgl.cnsn.gov.cn/website-webapp/wcm/initEdit_manuscript.action?websiteId=&manuscriptId=" + manuscript_id + "&status=4&channelId=" + channel_id;
            %>
            <tr>
                <td height="25" width="25" align="center"><img src="/website-webapp/images/default/view/spot.gif"/></td>
                <td align="left" class="operationalmaintenanceview-center-dclrwbox1" width="381">
                    <a href="<%=url%>" target="_blank"><span class="wshorttitle_28"><%=title%></span></a>
                </td>
                <td align="left" class="operationalmaintenanceview-center-dclrwbox2" title="" width="120">
                    <%
                        depsql2 = "select * from cms_user a join cms_department b on a.dept_id=b.dept_id where a.user_id ='"+userid+"'";
                        pst = conn.prepareStatement(depsql2);
                        rs2 = pst.executeQuery();
                        while (rs2.next()) {
                            undept = rs2.getString("name");
                        }
                    %>
                    <span class="shorttitle_9"><%=undept%></span>
                </td>
            </tr>
            <%
                }
            %>

        </table>
        <%
            closeConn(conn, pst, rs);
            /*  } catch (SQLException e1) {
             out.print("" + e1);
             }*/
        %>

    </body>
</html>
